package org.kamionowski.supreme.persistence.entity;

import java.io.Serializable;
import javax.persistence.Basic;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.SequenceGenerator;

/**
 * Created by IntelliJ IDEA.
 * User: Marcin Kamionowski
 * Date: 13.04.11
 * Time: 16:07
 */
@javax.persistence.Table(name = "search_tokens", schema = "public", catalog = "")
@Entity
public class Token implements Serializable{
    private Long id;

    public Token() {
    }

    @javax.persistence.Column(name = "id", nullable = false, insertable = true, updatable = true, length = 19, precision = 0)
    @Id
    @SequenceGenerator(name="tokenSeq")
    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    private Long hits;

    @javax.persistence.Column(name = "hits", nullable = false, insertable = true, updatable = true, length = 19, precision = 0)
    @Basic
    public Long getHits() {
        return hits;
    }

    public void setHits(Long hits) {
        this.hits = hits;
    }

    private Long resultscount;

    @javax.persistence.Column(name = "resultscount", nullable = false, insertable = true, updatable = true, length = 19, precision = 0)
    @Basic
    public Long getResultscount() {
        return resultscount;
    }

    public void setResultscount(Long resultscount) {
        this.resultscount = resultscount;
    }

    private String token;

    @javax.persistence.Column(name = "token", nullable = false, insertable = true, updatable = true, length = 200, precision = 0)
    @Basic
    public String getToken() {
        return token;
    }

    public void setToken(String token) {
        this.token = token;
    }

    public Token(Long hits, Long resultscount, String token) {
        this.hits = hits;
        this.resultscount = resultscount;
        this.token = token;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        Token that = (Token) o;

        if (hits != null ? !hits.equals(that.hits) : that.hits != null) return false;
        if (id != null ? !id.equals(that.id) : that.id != null) return false;
        if (resultscount != null ? !resultscount.equals(that.resultscount) : that.resultscount != null) return false;
        if (token != null ? !token.equals(that.token) : that.token != null) return false;

        return true;
    }

    @Override
    public int hashCode() {
        int result = id != null ? id.hashCode() : 0;
        result = 31 * result + (hits != null ? hits.hashCode() : 0);
        result = 31 * result + (resultscount != null ? resultscount.hashCode() : 0);
        result = 31 * result + (token != null ? token.hashCode() : 0);
        return result;
    }
}
